<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>登录</title>
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
    <link th:href="@{/css/font-awesome.css}" rel="stylesheet"/>
    <link th:href="@{/css/animate.css}" rel="stylesheet"/>
    <link th:href="@{/css/style.css}" rel="stylesheet"/>
</head>

<body class="gray-bg">
<div class="middle-box text-center loginscreen  animated fadeInDown">
    <div>
        <div>

            <h1 class="logo-name">Li</h1>

        </div>
        <h3>欢迎使用Light OA平台</h3>

        <form class="m-t" role="form" action="index.html">
            <div class="form-group">
                <input type="email" class="form-control" name="phone" placeholder="手机号" id="phone" required=""/>
            </div>
            <div class="form-group">
                <input type="password" class="form-control" name="pass" placeholder="密码" id="pass" required=""/>
            </div>
            <input type="button" value="登 录" onclick="checkAndLogin()" class="btn btn-primary block full-width m-b"/>
            <p class="text-muted text-center"> <a href="/toRegister">注册一个新账号</a>
            </p>

        </form>
    </div>
</div>

<!-- 全局js -->
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/js/plugins/layer/layer.js}"></script>

<!--<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>-->
<!--&lt;!&ndash;统计代码，可删除&ndash;&gt;-->
<script>
    function checkAndLogin() {
        var phone = $("#phone").val();
        var pass = $("#pass").val();
        if (phone == null || pass == null) {
            layer.msg("手机号或密码不能为空");
        }
        doLogin();
    }

    function doLogin() {
        var phone = $("#phone").val();
        var pass = $("#pass").val();
        $.ajax({
            url: "/user/login",
            type: "POST",
            data: {
                userPhone: phone,
                userPass: pass
            },
            success: function (data) {
                if (data.code == 200) {
                    window.location.href = "/toIndex";
                } else {
                    layer.msg(data.msg);
                }
            }
        });
    }
</script>
</body>

</html>
